\(\int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx\) [111]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [F]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 26, antiderivative size = 98 \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=\frac {i \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{\sqrt {2} \sqrt {a} d}-\frac {i}{d \sqrt {a+i a \tan (c+d x)}}-\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d} \]

[Out]

1/2*I*arctanh(1/2*(a+I*a*tan(d*x+c))^(1/2)*2^(1/2)/a^(1/2))/d*2^(1/2)/a^(1/2)-I/d/(a+I*a*tan(d*x+c))^(1/2)-2*I
*(a+I*a*tan(d*x+c))^(1/2)/a/d

Rubi [A] (verified)

Time = 0.12 (sec) , antiderivative size = 98, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.154, Rules used = {3624, 3560, 3561, 212} \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=\frac {i \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{\sqrt {2} \sqrt {a} d}-\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d}-\frac {i}{d \sqrt {a+i a \tan (c+d x)}} \]

[In]

Int[Tan[c + d*x]^2/Sqrt[a + I*a*Tan[c + d*x]],x]

[Out]

(I*ArcTanh[Sqrt[a + I*a*Tan[c + d*x]]/(Sqrt[2]*Sqrt[a])])/(Sqrt[2]*Sqrt[a]*d) - I/(d*Sqrt[a + I*a*Tan[c + d*x]
]) - ((2*I)*Sqrt[a + I*a*Tan[c + d*x]])/(a*d)

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3560

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[a*((a + b*Tan[c + d*x])^n/(2*b*d*n)), x] +
Dist[1/(2*a), Int[(a + b*Tan[c + d*x])^(n + 1), x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0] && LtQ[n
, 0]

Rule 3561

Int[Sqrt[(a_) + (b_.)*tan[(c_.) + (d_.)*(x_)]], x_Symbol] :> Dist[-2*(b/d), Subst[Int[1/(2*a - x^2), x], x, Sq
rt[a + b*Tan[c + d*x]]], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0]

Rule 3624

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
d^2*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e
 + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1] &&  !(EqQ[m, 2] && EqQ
[a, 0])

Rubi steps \begin{align*} \text {integral}& = -\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d}-\int \frac {1}{\sqrt {a+i a \tan (c+d x)}} \, dx \\ & = -\frac {i}{d \sqrt {a+i a \tan (c+d x)}}-\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d}-\frac {\int \sqrt {a+i a \tan (c+d x)} \, dx}{2 a} \\ & = -\frac {i}{d \sqrt {a+i a \tan (c+d x)}}-\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d}+\frac {i \text {Subst}\left (\int \frac {1}{2 a-x^2} \, dx,x,\sqrt {a+i a \tan (c+d x)}\right )}{d} \\ & = \frac {i \text {arctanh}\left (\frac {\sqrt {a+i a \tan (c+d x)}}{\sqrt {2} \sqrt {a}}\right )}{\sqrt {2} \sqrt {a} d}-\frac {i}{d \sqrt {a+i a \tan (c+d x)}}-\frac {2 i \sqrt {a+i a \tan (c+d x)}}{a d} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.29 (sec) , antiderivative size = 60, normalized size of antiderivative = 0.61 \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=-\frac {i \left (2+\operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},\frac {1}{2} (1+i \tan (c+d x))\right )+2 i \tan (c+d x)\right )}{d \sqrt {a+i a \tan (c+d x)}} \]

[In]

Integrate[Tan[c + d*x]^2/Sqrt[a + I*a*Tan[c + d*x]],x]

[Out]

((-I)*(2 + Hypergeometric2F1[-1/2, 1, 1/2, (1 + I*Tan[c + d*x])/2] + (2*I)*Tan[c + d*x]))/(d*Sqrt[a + I*a*Tan[
c + d*x]])

Maple [A] (verified)

Time = 0.93 (sec) , antiderivative size = 75, normalized size of antiderivative = 0.77

method result size
derivativedivides \(\frac {2 i \left (-\sqrt {a +i a \tan \left (d x +c \right )}+\frac {\sqrt {a}\, \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{4}-\frac {a}{2 \sqrt {a +i a \tan \left (d x +c \right )}}\right )}{d a}\) \(75\)
default \(\frac {2 i \left (-\sqrt {a +i a \tan \left (d x +c \right )}+\frac {\sqrt {a}\, \sqrt {2}\, \operatorname {arctanh}\left (\frac {\sqrt {a +i a \tan \left (d x +c \right )}\, \sqrt {2}}{2 \sqrt {a}}\right )}{4}-\frac {a}{2 \sqrt {a +i a \tan \left (d x +c \right )}}\right )}{d a}\) \(75\)

[In]

int(tan(d*x+c)^2/(a+I*a*tan(d*x+c))^(1/2),x,method=_RETURNVERBOSE)

[Out]

2*I/d/a*(-(a+I*a*tan(d*x+c))^(1/2)+1/4*a^(1/2)*2^(1/2)*arctanh(1/2*(a+I*a*tan(d*x+c))^(1/2)*2^(1/2)/a^(1/2))-1
/2*a/(a+I*a*tan(d*x+c))^(1/2))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 238 vs. \(2 (73) = 146\).

Time = 0.24 (sec) , antiderivative size = 238, normalized size of antiderivative = 2.43 \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=\frac {{\left (i \, \sqrt {2} a d \sqrt {\frac {1}{a d^{2}}} e^{\left (i \, d x + i \, c\right )} \log \left (4 \, {\left ({\left (a d e^{\left (2 i \, d x + 2 i \, c\right )} + a d\right )} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}} \sqrt {\frac {1}{a d^{2}}} + a e^{\left (i \, d x + i \, c\right )}\right )} e^{\left (-i \, d x - i \, c\right )}\right ) - i \, \sqrt {2} a d \sqrt {\frac {1}{a d^{2}}} e^{\left (i \, d x + i \, c\right )} \log \left (-4 \, {\left ({\left (a d e^{\left (2 i \, d x + 2 i \, c\right )} + a d\right )} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}} \sqrt {\frac {1}{a d^{2}}} - a e^{\left (i \, d x + i \, c\right )}\right )} e^{\left (-i \, d x - i \, c\right )}\right ) - 2 \, \sqrt {2} \sqrt {\frac {a}{e^{\left (2 i \, d x + 2 i \, c\right )} + 1}} {\left (5 i \, e^{\left (2 i \, d x + 2 i \, c\right )} + i\right )}\right )} e^{\left (-i \, d x - i \, c\right )}}{4 \, a d} \]

[In]

integrate(tan(d*x+c)^2/(a+I*a*tan(d*x+c))^(1/2),x, algorithm="fricas")

[Out]

1/4*(I*sqrt(2)*a*d*sqrt(1/(a*d^2))*e^(I*d*x + I*c)*log(4*((a*d*e^(2*I*d*x + 2*I*c) + a*d)*sqrt(a/(e^(2*I*d*x +
 2*I*c) + 1))*sqrt(1/(a*d^2)) + a*e^(I*d*x + I*c))*e^(-I*d*x - I*c)) - I*sqrt(2)*a*d*sqrt(1/(a*d^2))*e^(I*d*x
+ I*c)*log(-4*((a*d*e^(2*I*d*x + 2*I*c) + a*d)*sqrt(a/(e^(2*I*d*x + 2*I*c) + 1))*sqrt(1/(a*d^2)) - a*e^(I*d*x
+ I*c))*e^(-I*d*x - I*c)) - 2*sqrt(2)*sqrt(a/(e^(2*I*d*x + 2*I*c) + 1))*(5*I*e^(2*I*d*x + 2*I*c) + I))*e^(-I*d
*x - I*c)/(a*d)

Sympy [F]

\[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=\int \frac {\tan ^{2}{\left (c + d x \right )}}{\sqrt {i a \left (\tan {\left (c + d x \right )} - i\right )}}\, dx \]

[In]

integrate(tan(d*x+c)**2/(a+I*a*tan(d*x+c))**(1/2),x)

[Out]

Integral(tan(c + d*x)**2/sqrt(I*a*(tan(c + d*x) - I)), x)

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.03 \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=-\frac {i \, {\left (\sqrt {2} a^{\frac {5}{2}} \log \left (-\frac {\sqrt {2} \sqrt {a} - \sqrt {i \, a \tan \left (d x + c\right ) + a}}{\sqrt {2} \sqrt {a} + \sqrt {i \, a \tan \left (d x + c\right ) + a}}\right ) + 8 \, \sqrt {i \, a \tan \left (d x + c\right ) + a} a^{2} + \frac {4 \, a^{3}}{\sqrt {i \, a \tan \left (d x + c\right ) + a}}\right )}}{4 \, a^{3} d} \]

[In]

integrate(tan(d*x+c)^2/(a+I*a*tan(d*x+c))^(1/2),x, algorithm="maxima")

[Out]

-1/4*I*(sqrt(2)*a^(5/2)*log(-(sqrt(2)*sqrt(a) - sqrt(I*a*tan(d*x + c) + a))/(sqrt(2)*sqrt(a) + sqrt(I*a*tan(d*
x + c) + a))) + 8*sqrt(I*a*tan(d*x + c) + a)*a^2 + 4*a^3/sqrt(I*a*tan(d*x + c) + a))/(a^3*d)

Giac [F]

\[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=\int { \frac {\tan \left (d x + c\right )^{2}}{\sqrt {i \, a \tan \left (d x + c\right ) + a}} \,d x } \]

[In]

integrate(tan(d*x+c)^2/(a+I*a*tan(d*x+c))^(1/2),x, algorithm="giac")

[Out]

integrate(tan(d*x + c)^2/sqrt(I*a*tan(d*x + c) + a), x)

Mupad [B] (verification not implemented)

Time = 0.29 (sec) , antiderivative size = 83, normalized size of antiderivative = 0.85 \[ \int \frac {\tan ^2(c+d x)}{\sqrt {a+i a \tan (c+d x)}} \, dx=-\frac {1{}\mathrm {i}}{d\,\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}}-\frac {\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}\,2{}\mathrm {i}}{a\,d}-\frac {\sqrt {2}\,\mathrm {atan}\left (\frac {\sqrt {2}\,\sqrt {a+a\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}}{2\,\sqrt {-a}}\right )\,1{}\mathrm {i}}{2\,\sqrt {-a}\,d} \]

[In]

int(tan(c + d*x)^2/(a + a*tan(c + d*x)*1i)^(1/2),x)

[Out]

- 1i/(d*(a + a*tan(c + d*x)*1i)^(1/2)) - ((a + a*tan(c + d*x)*1i)^(1/2)*2i)/(a*d) - (2^(1/2)*atan((2^(1/2)*(a
+ a*tan(c + d*x)*1i)^(1/2))/(2*(-a)^(1/2)))*1i)/(2*(-a)^(1/2)*d)